package com.ruoyi.comment.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.comment.mapper.SysCommentMapper;
import com.ruoyi.comment.domain.SysComment;
import com.ruoyi.comment.service.ISysCommentService;

/**
 * 评论管理Service业务层处理
 * 
 * @author zzzyh
 * @date 2025-09-16
 */
@Service
public class SysCommentServiceImpl implements ISysCommentService 
{
    @Autowired
    private SysCommentMapper sysCommentMapper;

    /**
     * 查询评论管理
     * 
     * @param id 评论管理主键
     * @return 评论管理
     */
    @Override
    public SysComment selectSysCommentById(Long id)
    {
        return sysCommentMapper.selectSysCommentById(id);
    }

    /**
     * 查询评论管理列表
     * 
     * @param sysComment 评论管理
     * @return 评论管理
     */
    @Override
    public List<SysComment> selectSysCommentList(SysComment sysComment)
    {
        return sysCommentMapper.selectSysCommentList(sysComment);
    }

    /**
     * 新增评论管理
     * 
     * @param sysComment 评论管理
     * @return 结果
     */
    @Override
    public int insertSysComment(SysComment sysComment)
    {
        sysComment.setCreateTime(DateUtils.getNowDate());
        return sysCommentMapper.insertSysComment(sysComment);
    }

    /**
     * 修改评论管理
     * 
     * @param sysComment 评论管理
     * @return 结果
     */
    @Override
    public int updateSysComment(SysComment sysComment)
    {
        return sysCommentMapper.updateSysComment(sysComment);
    }

    /**
     * 批量删除评论管理
     * 
     * @param ids 需要删除的评论管理主键
     * @return 结果
     */
    @Override
    public int deleteSysCommentByIds(Long[] ids)
    {
        return sysCommentMapper.deleteSysCommentByIds(ids);
    }

    /**
     * 删除评论管理信息
     * 
     * @param id 评论管理主键
     * @return 结果
     */
    @Override
    public int deleteSysCommentById(Long id)
    {
        return sysCommentMapper.deleteSysCommentById(id);
    }
    @Override
    public String getUserInfoById(Long userId){
        return sysCommentMapper.getUserInfoById(userId);
    }

    @Override
    public String getArticleTitleById(Long articleId){
        return sysCommentMapper.getArticleTitleById(articleId);
    }

    @Override
    public Long getArticleIdByTitle(String articleTitle) {
        Long articleIdByTitle = sysCommentMapper.getArticleIdByTitle(articleTitle);
        return articleIdByTitle!=null?articleIdByTitle:-1L;
    }

    @Override
    public Long getUserIdByNickname(String nickName) {
        Long id = sysCommentMapper.getUserIdByNickname(nickName);
        return id!=null?id:-1L;
    }
}
